package a.f.h.d;

import a.c.d;
import a.c.m;
import a.c.q;
import a.c.z;
import a.f.fd;
import a.f.j.cb;
import a.f.kc;
import a.f.qb;
import a.f.sb;

public class s
  implements ab
{
  private static int t = 0;
  private static boolean u = false;
  protected q v;
  protected a.f.h.b.f w;
  protected y x;
  protected q y;
  protected qb z;
  protected c A;
  protected boolean B = true;
  protected z C;
  protected int D;
  private boolean E = false;
  protected a.c.x F;
  protected a.c.n G;
  protected a.c.n H;
  protected a.c.n I;
  protected int J = -1;
  protected int K = -1;
  protected int L;
  public static int M;
  
  public s(a.f.h.b.f paramf, short paramShort, int paramInt)
  {
    this.v = paramf.a();
    this.w = paramf;
    this.D = paramInt;
    if (i == 0)
    {
      if (this.D < 1) {
        throw new IllegalArgumentException("Invalid grid distance !");
      }
      this.x = a(paramShort);
    }
    if (i == 0) {
      if (this.x == null) {
        throw new IllegalArgumentException("Invalid node model !");
      }
    }
    this.B = this.x.a();
  }
  
  protected y a(short paramShort)
  {
    switch (paramShort)
    {
    case 3: 
      return new f();
    case 2: 
      return new x(this.D);
    case 1: 
      return new v(this.D);
    case 4: 
      return new n();
    case 0: 
      return new g(this.D);
    }
    return null;
  }
  
  public static void a(boolean paramBoolean)
  {
    int i = j.r;
    if (i == 0) {
      if (paramBoolean)
      {
        t = 1;
        u = true;
        if (i == 0) {
          if (!j.q) {
            return;
          }
        }
      }
      else
      {
        t = 0;
      }
    }
    u = false;
  }
  
  public boolean a()
  {
    return this.E;
  }
  
  public void b(boolean paramBoolean)
  {
    this.E = paramBoolean;
  }
  
  public c b()
  {
    return this.A;
  }
  
  public z c()
  {
    return this.C;
  }
  
  public void d()
  {
    int m = j.r;
    boolean bool = j.q;
    this.x.a(this.w);
    a.c.x localx = this.v.B();
    a.f.j.n localn = this.w.d();
    d locald1 = localn.a().a();
    double d = 30.0D;
    a.c.n localn1 = this.v.C();
    this.y = new q();
    if (m == 0)
    {
      if (u) {
        this.z = new qb();
      }
      this.A = new c(this.y);
      this.F = this.v.B();
      f();
      this.G = this.v.C();
      this.H = this.v.C();
      g();
      a(this.w, this.A);
    }
    boolean[] arrayOfBoolean = this.w.t();
    a.i.n.a(this, 3, "-----> Create edges for nodes:");
    Object localObject1 = this.v.v();
    Object localObject3;
    Object localObject4;
    Object localObject5;
    label571:
    label634:
    do
    {
      if (!((a.c.w)localObject1).e()) {
        break;
      }
      localObject2 = null;
      localObject3 = ((a.c.w)localObject1).d();
      localObject4 = new a.c.e[4];
      localObject5 = (b_)this.F.get(localObject3);
      localObject4[0] = ((b_)localObject5).a();
      localObject4[1] = ((b_)localObject5).e();
      localObject4[2] = ((b_)localObject5).d();
      localObject4[3] = ((b_)localObject5).b();
      if (bool) {
        break label756;
      }
      d locald2 = a((a.c.e)localObject3);
      if (locald2 != null) {
        localObject2 = ((a.c.e)localObject3).b(locald2);
      }
      d locald3 = locald2;
      int i = 0;
      do
      {
        do
        {
          if (i >= 4) {
            break label738;
          }
          if (bool) {
            break;
          }
          int j = locald2 != null ? 1 : 0;
          a.c.e locale1 = localObject4[i];
          int k = t;
          do
          {
            do
            {
              do
              {
                do
                {
                  if (j == 0) {
                    break label667;
                  }
                  if (bool) {
                    break label675;
                  }
                  if (this.w.h(locald3) != i) {
                    break label659;
                  }
                  a.c.e locale2 = (a.c.e)this.G.get(locald3);
                  a.c.e locale3 = (a.c.e)this.H.get(locald3);
                  d locald4 = a((a.c.e)localObject3, locale1, locale2, i, d, k);
                  localx.a(localObject3, locald4);
                  locale1 = (a.c.e)this.G.get(locald3);
                  d locald5 = this.y.a(locale2, locale3);
                  if (m == 0)
                  {
                    if (arrayOfBoolean[locald3.d()] != 0) {
                      this.A.u(locald5);
                    }
                    this.A.a(locald5, this.w.f(locald3));
                    this.A.c(locald5, 1.0D);
                    if (m != 0) {}
                  }
                  else if (this.w.k(locald3))
                  {
                    this.A.c(locald5, Math.max(this.w.j(locald3), 1));
                    if (m != 0) {
                      break label634;
                    }
                    if (!bool) {
                      break label571;
                    }
                  }
                  this.A.c(locald5, 1);
                  this.A.e(locald5, this.w.m(locald3));
                  this.A.f(locald5, this.w.n(locald3));
                  localn1.a(locald3, locald5);
                  ((m)localObject2).b();
                  locald3 = ((m)localObject2).a();
                  if (m != 0) {
                    break;
                  }
                } while (locald3 != locald2);
                j = 0;
                if (m != 0) {
                  break label664;
                }
              } while (!bool);
              j = 0;
            } while (!bool);
          } while (m != 0);
          if (i == 3)
          {
            a((a.c.e)localObject3, locale1, localObject4[0], 3, d, t);
            if (m != 0) {
              continue;
            }
            if (!bool) {}
          }
          else
          {
            a((a.c.e)localObject3, locale1, localObject4[(i + 1)], i, d, t);
          }
          i++;
        } while (!bool);
        ((a.c.w)localObject1).f();
      } while (m != 0);
    } while (!bool);
    label659:
    label664:
    label667:
    label675:
    label738:
    label756:
    localObject1 = this.v.w();
    do
    {
      if (!((m)localObject1).e()) {
        break;
      }
      localObject2 = ((m)localObject1).a();
      if (m != 0) {
        break label905;
      }
      if (bool) {
        break label902;
      }
      if (m == 0)
      {
        if (((d)localObject2).f().f() < ((d)localObject2).e().f())
        {
          localObject3 = this.w.a((d)localObject2);
          this.A.a((d)localn1.get(localObject2), (d)localn1.get(localObject3));
        }
        ((m)localObject1).f();
      }
    } while (!bool);
    a.i.n.a(this, 3, "Create Faces:");
    this.A.g();
    i();
    if (m == 0) {}
    label902:
    label905:
    localObject1 = (d)localn1.get(locald1);
    this.A.a(this.A.b((d)localObject1));
    this.C = new z();
    Object localObject2 = this.v.v();
    do
    {
      if (!((a.c.w)localObject2).e()) {
        break;
      }
      localObject3 = ((a.c.w)localObject2).d();
      if (bool) {
        break label1042;
      }
      if (m == 0)
      {
        if (this.x.a((a.c.e)localObject3))
        {
          localObject4 = (d)localx.get(localObject3);
          localObject5 = this.A.b((d)localObject4);
          this.C.add(localObject5);
        }
        ((a.c.w)localObject2).f();
      }
    } while (!bool);
    if (m == 0) {
      h();
    }
    label1042:
    localObject2 = this.y.w();
    do
    {
      do
      {
        if (!((m)localObject2).e()) {
          break;
        }
        localObject3 = ((m)localObject2).a();
        if (bool) {
          break label1187;
        }
        if (this.A.h(((d)localObject3).e()))
        {
          if (m != 0) {
            continue;
          }
          if (this.A.h(((d)localObject3).f()))
          {
            if (m != 0) {
              continue;
            }
            if (!this.A.k((d)localObject3)) {
              this.A.c((d)localObject3, 0);
            }
          }
        }
        ((m)localObject2).f();
      } while (!bool);
      a.i.n.a(this, 3, "-----> Center Edges:");
      this.I = this.v.C();
    } while (m != 0);
    localObject2 = this.v.w();
    label1187:
    if (((m)localObject2).e()) {}
    do
    {
      this.I.a(((m)localObject2).a(), 0.0D);
      ((m)localObject2).f();
      if (m != 0) {
        break label1258;
      }
      if (bool) {
        break label1255;
      }
      if (!bool) {
        break;
      }
      e();
      this.v.a(localn1);
    } while (m != 0);
    this.v.a(localx);
    label1255:
    label1258:
    if ((m != 0) || (q.n))
    {
      if (m == 0) {}
      j.q = !bool;
    }
    if (q.o)
    {
      m++;
      j.r = m;
    }
  }
  
  private void a(a.f.h.b.f paramf1, a.f.h.b.f paramf2)
  {
    boolean bool = j.q;
    a.c.y localy = paramf1.l();
    do
    {
      if (!localy.e()) {
        break;
      }
      a.f.h.b.j localj = (a.f.h.b.j)localy.j();
      paramf2.a(a(localj));
      localy.f();
    } while (!bool);
  }
  
  private a.f.h.b.j a(a.f.h.b.j paramj)
  {
    int i = j.r;
    boolean bool = j.q;
    a.c.e locale1 = paramj.a();
    a.c.e locale2 = paramj.b();
    b_ localb_1 = (b_)this.F.get(locale1);
    b_ localb_2 = (b_)this.F.get(locale2);
    a.f.h.b.k localk = paramj.e();
    if (i == 0) {
      if (localk == a.f.h.b.k.c)
      {
        localj = new a.f.h.b.j(localb_1.b(), localb_2.a(), paramj.c(), paramj.d(), localk);
        if (!bool) {
          break label242;
        }
      }
    }
    if (i == 0) {
      if (localk == a.f.h.b.k.a)
      {
        localj = new a.f.h.b.j(localb_1.a(), localb_2.b(), paramj.c(), paramj.d(), localk);
        if (!bool) {
          break label242;
        }
      }
    }
    if (localk == a.f.h.b.k.b)
    {
      if (i != 0) {
        break label240;
      }
      localj = new a.f.h.b.j(localb_1.e(), localb_2.a(), paramj.c(), paramj.d(), localk);
      if (!bool) {
        break label242;
      }
    }
    label240:
    a.f.h.b.j localj = new a.f.h.b.j(localb_1.a(), localb_2.e(), paramj.c(), paramj.d(), localk);
    label242:
    return localj;
  }
  
  protected void e()
  {
    int i = j.r;
    if (i == 0) {
      if (this.x.d())
      {
        if (i != 0) {
          break label35;
        }
        k();
        if (!j.q) {
          return;
        }
      }
    }
    label35:
    j();
  }
  
  private void f()
  {
    int i = j.r;
    boolean bool = j.q;
    a.c.w localw = this.v.v();
    do
    {
      if (!localw.e()) {
        break;
      }
      a.c.e locale1 = localw.d();
      Object localObject;
      if ((i != 0) || (!this.x.a(locale1)))
      {
        localObject = this.y.i();
        if (i == 0) {
          if (this.w.d(locale1)) {
            this.A.c((a.c.e)localObject);
          }
        }
        if (i == 0) {
          if (this.w.h(locale1)) {
            this.A.g((a.c.e)localObject);
          }
        }
        if (i == 0)
        {
          if (this.w.b(locale1)) {
            this.A.c((a.c.e)localObject);
          }
          this.F.a(locale1, new a_((a.c.e)localObject));
        }
        if (i != 0) {
          continue;
        }
        if (!bool) {}
      }
      else
      {
        localObject = new c_();
        a.c.e locale2 = this.y.i();
        this.A.j(locale2);
        ((c_)localObject).a(locale2);
        a.c.e locale3 = this.y.i();
        this.A.j(locale3);
        ((c_)localObject).e(locale3);
        a.c.e locale4 = this.y.i();
        this.A.j(locale4);
        ((c_)localObject).d(locale4);
        a.c.e locale5 = this.y.i();
        this.A.j(locale5);
        ((c_)localObject).c(locale5);
        this.F.a(locale1, localObject);
      }
      localw.f();
    } while (!bool);
  }
  
  protected d a(a.c.e parame)
  {
    int m = j.r;
    boolean bool = j.q;
    if (m == 0) {
      if (parame.e() == 0) {
        return null;
      }
    }
    short[] arrayOfShort = { 0, 0, 0, 0 };
    int i = 4;
    d locald = null;
    m localm = parame.n();
    do
    {
      do
      {
        if (!localm.e()) {
          break;
        }
        locald = localm.a();
        int k = this.w.h(locald);
        arrayOfShort[k] = 1;
        if (bool) {
          break label137;
        }
        if (k < i) {
          i = k;
        }
        localm.f();
      } while (!bool);
    } while (m != 0);
    if (arrayOfShort[0] + arrayOfShort[1] + arrayOfShort[2] + arrayOfShort[3] != 1)
    {
      label137:
      localm = parame.n();
      j = 1;
      do
      {
        do
        {
          if (j == 0) {
            break;
          }
          locald = localm.a();
          if (bool) {
            break label233;
          }
          if (this.w.h(locald) != i) {
            j = 0;
          }
          localm.b();
        } while (!bool);
      } while (m != 0);
      j = 1;
      if (j != 0)
      {
        if (!bool) {
          locald = localm.a();
        }
      }
      else {
        label233:
        while (m != 0)
        {
          if (this.w.h(locald) == i) {
            j = 0;
          }
          localm.b();
          if (!bool) {
            break;
          }
        }
      }
      return locald;
    }
    int j = 1;
    localm = parame.n();
    if (j != 0)
    {
      if (!bool) {
        locald = localm.a();
      }
    }
    else {
      while (m != 0)
      {
        if (m == 0)
        {
          if (this.w.e(locald) == 4) {
            j = 0;
          }
          localm.b();
        }
        if (!bool) {
          break;
        }
      }
    }
    return locald;
  }
  
  private d a(a.c.e parame1, a.c.e parame2, a.c.e parame3, int paramInt1, double paramDouble, int paramInt2)
  {
    int i = j.r;
    if (i == 0) {
      if (parame2.equals(parame3)) {
        return null;
      }
    }
    a.f.h.b.k localk1 = a.f.h.b.k.a(paramInt1).a();
    a.f.h.b.k localk2 = a.f.h.b.k.a(paramInt1).b();
    d locald1 = this.y.a(parame2, parame3);
    this.A.a(locald1, localk1.toString());
    this.A.c(locald1, paramDouble);
    this.A.c(locald1, paramInt2);
    m localm = parame3.n();
    d locald2;
    if (i == 0)
    {
      if (!localm.e())
      {
        locald2 = this.y.a(parame3, parame2);
        if (i != 0) {
          break label209;
        }
        if (!j.q) {}
      }
      else
      {
        localm.f();
      }
    }
    else
    {
      d locald3 = localm.a();
      locald2 = this.y.a(parame3, locald3, parame2, null, 1, 0);
    }
    this.A.a(locald2, localk2.toString());
    this.A.c(locald2, paramDouble);
    this.A.c(locald2, paramInt2);
    this.A.a(locald1, locald2);
    label209:
    return locald2;
  }
  
  private void g()
  {
    int k = j.r;
    boolean bool = j.q;
    Object localObject1 = this.v.v();
    Object localObject2;
    Object localObject3;
    label142:
    label144:
    label147:
    do
    {
      if (!((a.c.w)localObject1).e()) {
        break;
      }
      localObject2 = ((a.c.w)localObject1).d();
      localObject3 = this.w.k((a.c.e)localObject2);
      if (bool) {
        break label164;
      }
      d locald = a((a.c.e)localObject2);
      int i = 0;
      do
      {
        do
        {
          if (i >= 4) {
            break label147;
          }
          if (bool) {
            break;
          }
          int j = 0;
          do
          {
            if (j >= localObject3[i]) {
              break;
            }
            a.c.e locale = a(locald);
            this.G.a(locald, locale);
            locald = this.w.b().d(locald);
            j++;
            if (k != 0) {
              break label144;
            }
            if (bool) {
              break label142;
            }
          } while (!bool);
          if (k == 0) {
            i++;
          }
        } while (!bool);
        ((a.c.w)localObject1).f();
      } while (k != 0);
    } while (!bool);
    label164:
    localObject1 = this.v.w();
    do
    {
      if (!((m)localObject1).e()) {
        break;
      }
      localObject2 = ((m)localObject1).a();
      localObject3 = this.w.a((d)localObject2);
      this.H.a(localObject2, this.G.get(localObject3));
      this.H.a(localObject3, this.G.get(localObject2));
      ((m)localObject1).f();
    } while (!bool);
  }
  
  private a.c.e a(d paramd)
  {
    int i = j.r;
    if (i == 0) {
      if (!this.x.a(paramd.e()))
      {
        b_ localb_ = (b_)this.F.get(paramd.e());
        locale = localb_.a();
        if (i != 0) {
          break label69;
        }
        if (!j.q) {
          return locale;
        }
      }
    }
    a.c.e locale = this.y.i();
    label69:
    this.A.f(locale);
    return locale;
  }
  
  private void h()
  {
    int j = j.r;
    boolean bool = j.q;
    a.c.w localw = this.v.v();
    do
    {
      if (!localw.e()) {
        break;
      }
      a.c.e locale1 = localw.d();
      if (j == 0)
      {
        if (this.x.a(locale1))
        {
          b_ localb_ = (b_)this.F.get(locale1);
          a.c.e locale2 = localb_.a();
          a.c.e locale3 = localb_.d();
          if (j == 0) {}
          int i = this.x.b(locale1) ? 0 : 1;
          a.f.h.b.j localj1 = new a.f.h.b.j(locale2, locale3, this.x.c(locale1), i, a.f.h.b.k.b);
          this.A.a(localj1);
          a.f.h.b.j localj2 = new a.f.h.b.j(locale2, locale3, this.x.d(locale1), i, a.f.h.b.k.c);
          this.A.a(localj2);
        }
        localw.f();
      }
    } while (!bool);
  }
  
  private void i()
  {
    int k = j.r;
    boolean bool = j.q;
    a.f.j.o localo = this.A.c();
    label61:
    do
    {
      if (!localo.e()) {
        break;
      }
      a.f.j.n localn = localo.a();
      m localm = localn.a();
      Object localObject = localm.a();
      localm.f();
      d locald1 = localm.a();
      break label131;
      d locald2 = localm.a();
      a.f.h.b.k localk = this.A.i((d)localObject).d();
      int i = localk.g();
      do
      {
        int j = this.A.h(locald2);
        this.A.a(locald2, a.f.h.b.k.a(j - i).g());
        localObject = locald2;
        localm.b();
        if (localm.a() != locald1) {
          break label61;
        }
        localo.f();
        if (bool) {
          break;
        }
      } while (k != 0);
    } while (!bool);
    label131:
  }
  
  private void j()
  {
    int k = j.r;
    boolean bool = j.q;
    a.i.n.a(this, 1, "Do not center edges !");
    a.c.w localw = this.v.v();
    label328:
    label336:
    do
    {
      do
      {
        if (!localw.e()) {
          break;
        }
        a.c.e locale1 = localw.d();
        if ((k != 0) || (this.x.a(locale1)))
        {
          int[][] arrayOfInt = this.w.l(locale1);
          int i = 0;
          do
          {
            if (i >= 4) {
              break label336;
            }
            a.f.h.b.k localk = a.f.h.b.k.a(i);
            int[] arrayOfInt1 = arrayOfInt[i];
            int j = arrayOfInt1[0] + arrayOfInt1[1] + arrayOfInt1[2];
            if (bool) {
              break;
            }
            if (j != 0)
            {
              a.c.ab localab1 = new a.c.ab();
              a.c.ab localab2 = new a.c.ab();
              d locald1 = a(locale1, localk, localab1, localab2, arrayOfInt1);
              a.c.ab localab3 = new a.c.ab();
              localab3.a(localab1.l());
              localab3.add(locald1);
              localab3.a(localab2.l());
              char c = localk.f() ? '>' : '_';
              d locald2 = null;
              m localm = localab3.l();
              do
              {
                if (!localm.e()) {
                  break label328;
                }
                d locald3 = locald2;
                locald2 = localm.a();
                if (bool) {
                  break;
                }
                if (locald3 != null)
                {
                  a.c.e locale2 = (a.c.e)this.G.get(locald3);
                  a.c.e locale3 = (a.c.e)this.G.get(locald2);
                  a.f.h.b.j localj = new a.f.h.b.j(locale2, locale3, 1, 1, a.f.h.b.k.a(c));
                  this.A.a(localj);
                }
                localm.f();
              } while (!bool);
            }
            i++;
          } while (!bool);
        }
        localw.f();
      } while (k != 0);
    } while (!bool);
  }
  
  private void k()
  {
    int i11 = j.r;
    boolean bool = j.q;
    a.c.k localk1 = this.w.a().c(a.f.h.b.e.a);
    a.c.k localk2 = this.w.a().c("MIN_DIST_DP_KEY");
    int i = ((this.x instanceof g)) && (localk1 != null) ? 1 : 0;
    a.c.w localw = this.v.v();
    label513:
    label537:
    label556:
    label825:
    label844:
    label866:
    label895:
    do
    {
      do
      {
        if (!localw.e()) {
          break;
        }
        a.c.e locale = localw.d();
        if ((i11 != 0) || (this.x.a(locale)))
        {
          b_ localb_ = (b_)this.F.get(locale);
          int[][] arrayOfInt = this.w.l(locale);
          int j = 0;
          do
          {
            if (j >= 4) {
              break label895;
            }
            a.f.h.b.k localk3 = a.f.h.b.k.a(j);
            int[] arrayOfInt1 = arrayOfInt[j];
            int k = arrayOfInt1[0] + arrayOfInt1[1] + arrayOfInt1[2];
            if (bool) {
              break;
            }
            if (k != 0)
            {
              a.c.ab localab1 = new a.c.ab();
              a.c.ab localab2 = new a.c.ab();
              d locald = a(locale, localk3, localab1, localab2, arrayOfInt1);
              localab2.j();
              int m = 0;
              int n = 0;
              if (i11 == 0) {
                if (localk3.f())
                {
                  n = this.x.e(locale);
                  m = this.x.c(locale);
                }
              }
              if (i11 == 0) {
                if (localk3.e())
                {
                  n = this.x.f(locale);
                  m = this.x.d(locale);
                }
              }
              int i1 = (int)this.x.b();
              int i2 = (int)Math.ceil(n / i1);
              int i3 = n;
              int i4 = n;
              int i5 = i2;
              int i6 = i2;
              if (localk2 != null)
              {
                if (i11 != 0) {
                  break label556;
                }
                if (this.w.d(locale))
                {
                  h.a_ locala_ = (h.a_)localk2.get(locale);
                  if (i11 == 0)
                  {
                    if (locala_ != null)
                    {
                      double d = this.D / i1;
                      if (i11 == 0) {
                        if (localk3.f())
                        {
                          i3 += (int)Math.floor(locala_.c() / d);
                          i4 += (int)Math.floor(locala_.d() / d);
                          if (i11 != 0) {
                            break label537;
                          }
                          if (!bool) {
                            break label513;
                          }
                        }
                      }
                      if (i11 != 0) {
                        break label537;
                      }
                      if (localk3.e())
                      {
                        i3 += (int)Math.floor(locala_.a() / d);
                        i4 += (int)Math.floor(locala_.b() / d);
                      }
                    }
                    i5 = (int)Math.ceil(i3 / i1);
                  }
                  i6 = (int)Math.ceil(i4 / i1);
                }
              }
              int i7 = (int)Math.floor((m - i5 - i6) * 0.5D);
              if (i11 == 0)
              {
                a(localab1, localb_, m, i7, i1, i4 + i3, i5, true);
                if (locald != null) {
                  if ((i != 0) && ((i11 != 0) || (localk1.get(locale) != null)))
                  {
                    kc localkc = (kc)localk1.get(locale);
                    fd localfd = localkc.g();
                    a.f.h.b.k localk4 = this.w.d(locald) ? localk3.d() : localk3;
                    int i8 = (i11 != 0) || ((localk4 == a.f.h.b.k.a) || (localk4 == a.f.h.b.k.b)) ? 1 : 0;
                    int i9 = i7 + i2;
                    int i10 = i7 + i2;
                    if (i11 == 0) {
                      if (!localfd.n())
                      {
                        if (i11 != 0) {
                          break label777;
                        }
                        if (!localfd.o())
                        {
                          if (i11 == 0) {}
                          i9 = i8 != 0 ? 0 : 2 * i9;
                          if (i11 == 0) {}
                          i10 = i8 != 0 ? 2 * i10 : 0;
                          if (i11 != 0) {
                            break label844;
                          }
                          if (!bool) {
                            break label825;
                          }
                        }
                      }
                    }
                    if (i11 == 0)
                    {
                      if (localfd.n())
                      {
                        if (i11 == 0) {}
                        i9 = i8 != 0 ? 2 * i9 : 0;
                        if (i11 == 0) {}
                        i10 = i8 != 0 ? 0 : 2 * i10;
                      }
                      if (i11 != 0) {
                        break label866;
                      }
                      a(locald, localb_, i9, i10);
                    }
                    if (!bool) {}
                  }
                  else
                  {
                    a(locald, localb_, i7 + i5, i7 + i6);
                  }
                }
              }
              a(localab2, localb_, m, i7, i1, i4 + i3, i5, false);
            }
            j++;
          } while (!bool);
        }
        localw.f();
      } while (i11 != 0);
    } while (!bool);
    label777:
  }
  
  private void a(a.c.ab paramab, b_ paramb_, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, boolean paramBoolean)
  {
    int i3 = j.r;
    boolean bool = j.q;
    int i = paramab.size();
    if (i3 == 0) {
      if (i == 0) {
        return;
      }
    }
    if (i3 == 0) {}
    int j = paramBoolean ? 1 : -1;
    int[] arrayOfInt = new int[paramInt2 + 1];
    double d1 = 1.0D;
    if (i3 == 0) {
      if (paramInt2 > 0)
      {
        int k = (int)Math.ceil(i / paramInt2);
        m = k * paramInt2 - i;
        arrayOfInt[0] = ((int)Math.ceil(k * 0.5D));
        arrayOfInt[paramInt2] = ((int)Math.floor(k * 0.5D));
        n = 1;
        do
        {
          do
          {
            if (n >= paramInt2) {
              break;
            }
            arrayOfInt[n] = k;
            n++;
            if (i3 != 0) {
              break label164;
            }
            if (bool) {
              break label162;
            }
          } while (!bool);
        } while (i3 != 0);
        n = 0;
        label162:
        label164:
        do
        {
          if (n >= m) {
            break;
          }
          arrayOfInt[n] -= 1;
          n++;
          if (i3 != 0) {
            break label212;
          }
          if (bool) {
            break label210;
          }
        } while (!bool);
        if (i3 != 0) {
          break label264;
        }
        d1 = paramInt3 / k;
        label210:
        label212:
        if (i3 == 0) {
          if (!bool) {
            break label266;
          }
        }
      }
      else
      {
        arrayOfInt[0] = i;
      }
    }
    if (i3 == 0) {
      if (paramInt1 == 0)
      {
        d1 = 0.0D;
        if ((i3 == 0) && (!bool)) {
          break label266;
        }
      }
    }
    label264:
    d1 = (paramInt1 * paramInt3 - paramInt4) / (i * 2.0D);
    label266:
    m localm = paramab.l();
    int m = paramInt5 + paramInt2;
    int n = 0;
    label482:
    label484:
    do
    {
      if (n >= arrayOfInt.length) {
        break;
      }
      double d2 = 0.0D;
      if (i3 == 0) {
        if (n > 0) {
          d2 = -(int)Math.ceil((arrayOfInt[n] - 1) / 2.0D) * d1;
        }
      }
      if (i3 == 0) {
        if (n == arrayOfInt.length - 1) {
          d2 = -arrayOfInt[n] * d1;
        }
      }
      int i1 = 0;
      do
      {
        if (i1 >= arrayOfInt[n]) {
          break;
        }
        d locald = localm.a();
        int i2 = m - j * (paramInt2 - n);
        a(locald, paramb_, i2, paramInt1 - i2);
        localm.f();
        this.I.a(locald, j * d2);
        this.I.a(this.w.a(locald), j * d2);
        d2 += d1;
        i1++;
        if (i3 != 0) {
          break label484;
        }
        if (bool) {
          break label482;
        }
      } while (!bool);
      if (i3 == 0) {
        n++;
      }
    } while (!bool);
  }
  
  private void a(d paramd, b_ paramb_, int paramInt1, int paramInt2)
  {
    int i = j.r;
    a.f.h.b.j localj1 = null;
    a.f.h.b.j localj2 = null;
    a.c.e locale = (a.c.e)this.G.get(paramd);
    a.f.h.b.k localk = this.w.i(paramd);
    if (localk.c(a.f.h.b.k.d))
    {
      localj1 = new a.f.h.b.j(paramb_.a(), locale, paramInt1, 1, a.f.h.b.k.c);
      localj2 = new a.f.h.b.j(locale, paramb_.b(), paramInt2, 1, a.f.h.b.k.c);
    }
    if (i == 0) {
      if (localk.c(a.f.h.b.k.b))
      {
        localj1 = new a.f.h.b.j(paramb_.e(), locale, paramInt1, 1, a.f.h.b.k.c);
        localj2 = new a.f.h.b.j(locale, paramb_.d(), paramInt2, 1, a.f.h.b.k.c);
      }
    }
    if (i == 0) {
      if (localk.c(a.f.h.b.k.a))
      {
        localj1 = new a.f.h.b.j(paramb_.a(), locale, paramInt1, 1, a.f.h.b.k.b);
        localj2 = new a.f.h.b.j(locale, paramb_.e(), paramInt2, 1, a.f.h.b.k.b);
      }
    }
    if (localk.c(a.f.h.b.k.c))
    {
      localj1 = new a.f.h.b.j(paramb_.b(), locale, paramInt1, 1, a.f.h.b.k.b);
      localj2 = new a.f.h.b.j(locale, paramb_.d(), paramInt2, 1, a.f.h.b.k.b);
    }
    this.A.a(localj1);
    this.A.a(localj2);
  }
  
  protected d a(a.c.e parame, a.f.h.b.k paramk, a.c.ab paramab1, a.c.ab paramab2, int[] paramArrayOfInt)
  {
    int k = j.r;
    boolean bool = j.q;
    paramab1.clear();
    paramab2.clear();
    Object localObject = null;
    m localm = parame.b(a(parame));
    int i = 0;
    int j = paramArrayOfInt[0] + paramArrayOfInt[1] + paramArrayOfInt[2];
    if (j == 0) {
      return null;
    }
    a.c.ab localab1 = new a.c.ab();
    a.c.ab localab2 = new a.c.ab();
    label194:
    label195:
    do
    {
      if (i >= j) {
        break;
      }
      d locald = localm.a();
      if (bool) {
        break label222;
      }
      if (this.w.i(locald).c(paramk))
      {
        if (k == 0)
        {
          if (i < paramArrayOfInt[2])
          {
            localab1.add(locald);
            if ((k == 0) && (!bool)) {
              break label195;
            }
          }
          if (k != 0) {}
        }
        else if (i == paramArrayOfInt[2])
        {
          if (k != 0) {
            break label194;
          }
          if (paramArrayOfInt[1] == 1)
          {
            localObject = locald;
            if ((k == 0) && (!bool)) {
              break label195;
            }
          }
        }
        localab2.add(locald);
        i++;
      }
      localm.b();
    } while (!bool);
    if ((k != 0) || (!paramk.c(a.f.h.b.k.d)))
    {
      label222:
      if (k == 0) {
        if (!paramk.c(a.f.h.b.k.c)) {
          break label279;
        }
      }
    }
    else
    {
      localab1.j();
      localab2.j();
      paramab1.a(localab2.l());
      paramab2.a(localab1.l());
      if (k != 0) {
        break label288;
      }
    }
    if (bool)
    {
      label279:
      paramab1.a(localab1.l());
      label288:
      paramab2.a(localab2.l());
    }
    if (k == 0) {
      if (localObject == null) {
        if (k == 0)
        {
          if (paramab1.size() > paramab2.size())
          {
            if (k != 0) {
              break label370;
            }
            localObject = paramab1.n();
            paramab1.h(paramab1.g());
            if (!bool) {}
          }
          else
          {
            localObject = paramab2.m();
          }
        }
        else {
          paramab2.h(paramab2.f());
        }
      }
    }
    label370:
    return localObject;
  }
  
  public void a(a.c.x paramx, a.f.o paramo)
  {
    int n = j.r;
    boolean bool = j.q;
    a.i.n.a(this, "Grid: " + this.D);
    double d1 = this.D;
    double d2 = this.D;
    int i = 2147483647;
    int j = -2147483648;
    int k = 2147483647;
    int m = -2147483648;
    Object localObject1 = this.y.v();
    Object localObject2;
    Object localObject3;
    do
    {
      if (!((a.c.w)localObject1).e()) {
        break;
      }
      localObject2 = ((a.c.w)localObject1).d();
      localObject3 = (a.d.w)paramx.get(localObject2);
      i = Math.min(i, (int)((a.d.w)localObject3).a());
      j = Math.max(j, (int)((a.d.w)localObject3).a());
      k = Math.min(k, (int)((a.d.w)localObject3).b());
      m = Math.max(m, (int)((a.d.w)localObject3).b());
      ((a.c.w)localObject1).f();
      if ((n == 0) && (bool)) {
        break label208;
      }
    } while (!bool);
    this.J = (j - i);
    this.K = (m - k);
    label208:
    Object localObject4;
    label390:
    a.d.w localw1;
    if (n == 0)
    {
      this.L = 0;
      localObject1 = this.v.w();
      do
      {
        if (!((m)localObject1).e()) {
          break;
        }
        localObject2 = ((m)localObject1).a();
        localObject3 = (a.d.w)paramx.get(this.G.get(localObject2));
        localObject4 = (a.d.w)paramx.get(this.H.get(localObject2));
        if (bool) {
          break label390;
        }
        if (this.w.i((d)localObject2).c(a.f.h.b.k.b)) {
          this.L = ((int)(this.L + (((a.d.w)localObject4).a() - ((a.d.w)localObject3).a())));
        }
        if (n == 0)
        {
          if (this.w.i((d)localObject2).c(a.f.h.b.k.c)) {
            this.L = ((int)(this.L + (((a.d.w)localObject4).b() - ((a.d.w)localObject3).b())));
          }
          ((m)localObject1).f();
        }
      } while (!bool);
      if ((n == 0) && (u))
      {
        localObject1 = this.y.B();
        localObject2 = this.y.v();
        do
        {
          if (!((a.c.w)localObject2).e()) {
            break;
          }
          localObject3 = ((a.c.w)localObject2).d();
          localObject4 = (a.d.w)paramx.get(localObject3);
          localw1 = new a.d.w(((a.d.w)localObject4).a() * d1, ((a.d.w)localObject4).b() * d2);
          sb localsb = new sb();
          localsb.b(20.0D, 20.0D);
          localsb.c(localw1.a(), localw1.b());
          this.z.a(localObject3, localsb);
          ((a.c.x)localObject1).a(localObject3, "" + ((a.c.e)localObject3).f());
          if (n != 0) {
            break label595;
          }
          ((a.c.w)localObject2).f();
          if (bool) {
            break label588;
          }
        } while (!bool);
        if (n != 0) {
          break label592;
        }
        this.y.a((a.c.x)localObject1);
      }
    }
    a.i.n.a(this, 3, "Merging nodes:");
    label588:
    label592:
    label595:
    localObject1 = this.v.v();
    Object localObject5;
    do
    {
      if (!((a.c.w)localObject1).e()) {
        break;
      }
      localObject2 = ((a.c.w)localObject1).d();
      localObject3 = (b_)this.F.get(localObject2);
      localObject4 = (a.d.w)paramx.get(((b_)localObject3).a());
      localw1 = (a.d.w)paramx.get(((b_)localObject3).d());
      double d4 = (localw1.a() - ((a.d.w)localObject4).a()) * d1;
      double d6 = (localw1.b() - ((a.d.w)localObject4).b()) * d2;
      if (bool) {
        break label860;
      }
      if (!this.w.d((a.c.e)localObject2)) {
        paramo.b((a.c.e)localObject2, 0.0D, 0.0D);
      }
      if (this.B) {
        paramo.a((a.c.e)localObject2, new a.d.s(d4 + d1 / 2.0D, d6 + d2 / 2.0D));
      }
      localObject5 = paramo.u((a.c.e)localObject2);
      double d7 = ((a.d.s)localObject5).b();
      double d8 = ((a.d.s)localObject5).c();
      double d9 = ((a.d.w)localObject4).a() * d1 + (d4 - d7) / 2.0D;
      double d10 = ((a.d.w)localObject4).b() * d2 + (d6 - d8) / 2.0D;
      paramo.b((a.c.e)localObject2, new a.d.w(d9, d10));
      ((a.c.w)localObject1).f();
    } while (!bool);
    if (n == 0) {
      if (this.E) {
        label860:
        a(paramo);
      }
    }
    localObject1 = this.v.w();
    label1014:
    do
    {
      if (!((m)localObject1).e()) {
        break;
      }
      localObject2 = ((m)localObject1).a();
      localObject3 = ((d)localObject2).e();
      localObject4 = ((d)localObject2).f();
      double d3 = 0.0D;
      double d5 = 0.0D;
      if (n != 0) {
        return;
      }
      if (bool) {
        break label1558;
      }
      if (n == 0)
      {
        if (this.w.i((d)localObject2).f())
        {
          if (n != 0) {
            break label1031;
          }
          d3 = this.I.getDouble(localObject2) * this.D / this.x.b();
        }
      }
      else {
        if (!bool) {
          break label1014;
        }
      }
      d5 = this.I.getDouble(localObject2) * this.D / this.x.b();
      a.d.w localw2 = (a.d.w)paramx.get(this.G.get(localObject2));
      localObject5 = new a.d.w(localw2.a() * d1 + d3, localw2.b() * d2 + d5);
      a.d.w localw3 = (a.d.w)paramx.get(this.H.get(localObject2));
      a.d.w localw4 = new a.d.w(localw3.a() * d1 + d3, localw3.b() * d2 + d5);
      if (n == 0) {
        if (!this.B)
        {
          if (n == 0) {
            if (this.w.i((d)localObject2).c(a.f.h.b.k.d))
            {
              localObject5 = new a.d.w(paramo.p((a.c.e)localObject3), ((a.d.w)localObject5).b());
              localw4 = new a.d.w(paramo.p((a.c.e)localObject4) + paramo.s((a.c.e)localObject4), localw4.b());
            }
          }
          if (n == 0) {
            if (this.w.i((d)localObject2).c(a.f.h.b.k.b))
            {
              localObject5 = new a.d.w(paramo.p((a.c.e)localObject3) + paramo.s((a.c.e)localObject3), ((a.d.w)localObject5).b());
              localw4 = new a.d.w(paramo.p((a.c.e)localObject4), localw4.b());
            }
          }
          if (n == 0) {
            if (this.w.i((d)localObject2).c(a.f.h.b.k.a))
            {
              localObject5 = new a.d.w(((a.d.w)localObject5).a(), paramo.q((a.c.e)localObject3));
              localw4 = new a.d.w(localw4.a(), paramo.q((a.c.e)localObject4) + paramo.t((a.c.e)localObject4));
            }
          }
          if (n != 0) {
            break label1419;
          }
          if (this.w.i((d)localObject2).c(a.f.h.b.k.c))
          {
            localObject5 = new a.d.w(((a.d.w)localObject5).a(), paramo.q((a.c.e)localObject3) + paramo.t((a.c.e)localObject3));
            localw4 = new a.d.w(localw4.a(), paramo.q((a.c.e)localObject4));
          }
        }
      }
      if (n == 0)
      {
        if (this.w.d((a.c.e)localObject3)) {
          paramo.c((d)localObject2, (a.d.w)localObject5);
        }
      }
      else
      {
        if (n != 0) {
          break label1462;
        }
        if (!bool) {
          break label1453;
        }
      }
      paramo.a((a.c.e)localObject3, (a.d.w)localObject5);
      if (n == 0)
      {
        if (this.w.d((a.c.e)localObject4)) {
          paramo.d((d)localObject2, localw4);
        }
      }
      else
      {
        if (n != 0) {
          continue;
        }
        if (!bool) {
          break label1496;
        }
      }
      paramo.a((a.c.e)localObject4, localw4);
      ((m)localObject1).f();
    } while (!bool);
    label1031:
    label1419:
    label1453:
    label1462:
    label1496:
    this.v.a(this.F);
    this.v.a(this.I);
    this.v.a(this.G);
    this.v.a(this.H);
    if (n == 0) {
      label1558:
      this.x.e();
    }
  }
  
  private void a(a.f.o paramo)
  {
    int i = j.r;
    boolean bool = j.q;
    a.c.ab localab = new a.c.ab();
    cb localcb = (cb)this.w.b();
    m localm1 = this.v.w();
    d locald1;
    do
    {
      do
      {
        if (!localm1.e()) {
          break;
        }
        locald1 = localm1.a();
        if (bool) {
          break label157;
        }
        if (!localcb.h(locald1))
        {
          if (i != 0) {
            continue;
          }
          if (a(locald1, paramo))
          {
            if (i != 0) {
              continue;
            }
            if (localcb.e(locald1.e()))
            {
              if (i != 0) {
                continue;
              }
              if (localcb.e(locald1.f())) {
                localab.add(locald1);
              }
            }
          }
        }
        localm1.f();
      } while (!bool);
    } while (i != 0);
    localm1 = localab.l();
    label157:
    label696:
    label762:
    do
    {
      if (!localm1.e()) {
        break;
      }
      locald1 = localm1.a();
      m localm2 = locald1.e().m();
      if (localm2.a() != null) {}
      do
      {
        if (localcb.h(localm2.a())) {
          localm2.b();
        }
        Object localObject1 = localm2.a();
        Object localObject2 = localcb.b((d)localObject1);
        localm2 = locald1.f().n();
        if (localm2.a() != null)
        {
          if (localcb.h(localm2.a())) {
            localm2.b();
          }
          d locald2 = localm2.a();
          d locald3 = localcb.b(locald2);
          if ((i != 0) || ((!localcb.f(((d)localObject1).e())) || ((i != 0) || (!localcb.f(locald2.f())))))
          {
            if (i == 0) {
              if (!localcb.f(((d)localObject1).e()))
              {
                if (i == 0) {
                  if (!localcb.f(locald2.f())) {
                    break label932;
                  }
                }
              }
              else {
                if (i != 0) {
                  break label406;
                }
              }
            }
            if (!localcb.f(((d)localObject1).e()))
            {
              localObject1 = locald2;
              localObject2 = locald3;
            }
            localcb.h(locald1.e());
            d locald4 = localcb.h(locald1.f());
            localcb.o(locald4);
            d locald5 = localcb.b(locald4);
            this.I.a(locald4, this.I.getDouble(localObject1));
            this.I.a(locald5, this.I.getDouble(localObject1));
            this.w.a(locald4, this.w.f((d)localObject1));
            this.w.a(locald5, this.w.f((d)localObject2));
            this.G.a(locald4, this.G.get(localObject1));
            this.H.a(locald4, this.H.get(localObject1));
            this.H.a(locald5, this.G.get(localObject1));
            this.G.a(locald5, this.H.get(localObject1));
            Object localObject3 = locald4;
            d locald6;
            m localm3;
            d locald7;
            d locald8;
            do
            {
              if (!localcb.b(((d)localObject3).e())) {
                break label762;
              }
              locald6 = localcb.n((d)localObject3);
              localm3 = ((d)localObject3).e().b((d)localObject3);
              localm3.b();
              if (bool) {
                break label769;
              }
              locald7 = localm3.a();
              do
              {
                if (localcb.n(localcb.b(locald7)) == locald6) {
                  break label696;
                }
                localm3.b();
                locald7 = localm3.a();
                if ((i == 0) && (bool)) {
                  break;
                }
              } while (!bool);
              locald8 = localcb.b(locald7);
              this.I.a(locald8, this.I.getDouble(localObject1));
              this.I.a(locald7, this.I.getDouble(localObject1));
              localObject3 = locald8;
              if (i != 0) {
                break;
              }
            } while (!bool);
            if (i == 0) {
              localObject3 = locald4;
            }
            do
            {
              if (!localcb.b(((d)localObject3).f())) {
                break label932;
              }
              locald6 = localcb.n((d)localObject3);
              localm3 = ((d)localObject3).f().b((d)localObject3);
              localm3.b();
              if (bool) {
                break;
              }
              locald7 = localm3.a();
              do
              {
                if (localcb.n(locald7) == locald6) {
                  break label866;
                }
                localm3.b();
                locald7 = localm3.a();
                if ((i == 0) && (bool)) {
                  break;
                }
              } while (!bool);
              locald8 = localcb.b(locald7);
              this.I.a(locald7, this.I.getDouble(localObject1));
              this.I.a(locald8, this.I.getDouble(localObject1));
              localObject3 = locald7;
              if (i != 0) {
                break label770;
              }
            } while (!bool);
          }
        }
        localm1.f();
      } while (i != 0);
    } while (!bool);
    label406:
    label866:
    return;
  }
  
  private boolean a(d paramd, a.f.o paramo)
  {
    int i = j.r;
    if ((i != 0) || (paramo.p(paramd.e()) == paramo.p(paramd.f()))) {
      if (i != 0) {}
    }
    return paramo.q(paramd.e()) == paramo.q(paramd.f());
  }
  
  public int l()
  {
    return this.J;
  }
  
  public int m()
  {
    return this.K;
  }
  
  public int n()
  {
    return this.L;
  }
  
  static class a_
    implements s.b_
  {
    a.c.e a;
    
    a_(a.c.e parame)
    {
      this.a = parame;
    }
    
    public a.c.e a()
    {
      return this.a;
    }
    
    public a.c.e b()
    {
      return this.a;
    }
    
    public a.c.e d()
    {
      return this.a;
    }
    
    public a.c.e e()
    {
      return this.a;
    }
  }
  
  static class c_
    implements s.b_
  {
    a.c.e a;
    a.c.e c;
    a.c.e e;
    a.c.e f;
    
    void a(a.c.e parame)
    {
      this.a = parame;
    }
    
    void c(a.c.e parame)
    {
      this.c = parame;
    }
    
    void d(a.c.e parame)
    {
      this.e = parame;
    }
    
    void e(a.c.e parame)
    {
      this.f = parame;
    }
    
    public a.c.e a()
    {
      return this.a;
    }
    
    public a.c.e b()
    {
      return this.c;
    }
    
    public a.c.e d()
    {
      return this.e;
    }
    
    public a.c.e e()
    {
      return this.f;
    }
  }
  
  static abstract interface b_
  {
    public abstract a.c.e a();
    
    public abstract a.c.e b();
    
    public abstract a.c.e d();
    
    public abstract a.c.e e();
  }
}


/* Location:           E:\idea\
 * Qualified Name:     a.f.h.d.s
 * JD-Core Version:    0.7.0.1
 */